VMS Help  —  PASCAL  Data Types, Pointer Types
  A pointer type allows  you  to  refer  to  a  dynamic  variable.
  Dynamic  variables  do  not  have  lifetimes  that  are strictly
  related to the scope of a routine, module, or program;  you  can
  create  and  eliminate  them  at  various  times  during program
  execution.  Also, pointer types clearly define the  type  of  an
  object,  but  you can create or eliminate objects during program
  execution.  A pointer type has the following syntax:

     [[attribute-list]] ^ [[attribute-list]] base-type-identifier

  The 'attribute-list' is one or more  optional  identifiers  that
  provide additional information about the base type.

  The 'base-type-identifier' is the type identifier of the dynamic
  variable to which the pointer type refers.  (If the base type is
  an undiscriminated  schema  type,  you  need  to  supply  actual
  discriminants when you call the NEW function.)

  Unlike  other  variables,  dynamic   variables   do   not   have
  identifiers.  Instead, you access them indirectly with pointers.

  Call  the  NEW  procedure  to  allocate  storage   for   dynamic
  variables.   Call  the  DISPOSE  procedure  to  deallocate  this
  storage.

  Example:  TYPE
            Reservation = RECORD
              Name  : VARYING[30] OF CHAR;
              Class : ( standby, coach, first );
              Flight_number  : INTEGER;
              Next_passenger : ^Reservation;
              END;

            VAR
             Ticket : Reservation;

  In this example, 'Next_passenger' is a  pointer  to  the  record
  type  'Reservation'.   The variable 'Ticket' is declared as type
  'Reservation'.    By   manipulating   the   pointer    variable,
  'Ticket.Next_passenger', a linked list of records can be created
  using these definitions.

  By default,  all  pointer  types  are  32-bits  wide.   The  NEW
  procedure  uses LIB$GET_VM to allocate memory and LIB$FREE_VM to
  dispose of memory.  On OpenVMS Alpha and OpenVMS I64, the [QUAD]
  attribute may be specified before the "^" character resulting in
  a 64-bit pointer.  Using 64-bit  pointers  causes  the  NEW  and
  DISPOSE  procedures  to  LIB$GET_VM_64  to  allocate  memory and
  LIB$FREE_VM_64 to dispose of memory, respectively.

1  –  C_STR_T

  The C_STR_T  predefined  type  is  provided  to  interface  with
  routines   written  in  the  C  language  using  null-terminated
  strings.  C_STR_T behaves like a normal pointer type in that you
  can  assign  NIL  into it and the optional pointer checking code
  will check for dereferencing of a NIL pointer.   The  individual
  characters can be used by dereferencing the pointer and using an
  array index.  No bounds checking will be performed even if array
  bounds checking is enabled.

  You cannot dereference a C_STR_T pointer without also indexing a
  single   character.    If   you   want   to   access  an  entire
  null-terminated string, see the PAS_STR function.

2  –  POINTER

  The POINTER predefined  type  is  compatible  with  all  pointer
  types.   Variables  or  functions  of  type  POINTER  cannot  be
  dereferenced or used with the NEW and  DISPOSE  procedures.   In
  order to access the data, you must assign the pointer value into
  a variable of a particular pointer type or typecast the  pointer
  to  a  particular  pointer  type.   For example, you can use the
  POINTER type in the following ways:

   o  To assign to or from any other type  of  pointer,  including
      function result variables

   o  To compare equality with any other type of pointer

   o  To pass actual parameters of type POINTER to VAR  and  value
      parameters of any other type of pointer

   o  To accept parameters of  any  other  type  of  pointer  with
      formal parameters of type POINTER

3  –  UNIV_PTR

  The predefined UNIV_PTR type is equivalent to:

  TYPE
      UNIV_PTR = POINTER;
Close Help